package cn.zzf.core;

import java.io.File;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

/**
 * @author GaoFeng2017
 * @date 2018-02-20 11:11:27
 **/

public class LinkParse extends DataParse {

    protected LinkParse(File dataFileRoot) {
        super(dataFileRoot);
    }

    public List<LinkItem> teacherLinkParse() {

        List<LinkItem> linkItems = new ArrayList<>();

        for (Properties link : this.dataFiles) {
            LinkItem linkItem = new LinkItem();
            linkItem.setName(link.getProperty("name"));
            linkItem.setCategory(link.getProperty("category"));
            linkItem.setClassInfo(link.getProperty("class"));
            linkItem.setTeacher(link.getProperty("teacher"));
            linkItem.setTeems(Integer.valueOf(link.getProperty("teams")));
            linkItem.setCredit(new BigDecimal(link.getProperty("credit")));
            linkItem.setTotal_people(Integer.valueOf(link.getProperty("total_people")));
            linkItem.setWeek(link.getProperty("week"));
            linkItem.setWeeks(Integer.valueOf(link.getProperty("weeks").replace(".0","")));
            linkItems.add(linkItem);
        }

        return linkItems;
    }
}
